package com.sai.homework;

public class task01 {

   /* public static int show(){
        int sum = 0;
        for (int i = 0; i < 16; i++){
            for (int j = 0; j < 16; j++){
                sum += arr[i][j];
                System.out.println();
            }
        }
    }*/

    public static void main(String[] args) {
        int[][] arr = new int[16][16];
        for(int i = 0; i < 16; i++){
            for (int j = 0; j < 16; j++){
                arr[i][j] = i + j;
            }
        }
        int sum = 0;
        for (int i = 0; i < 16; i++){
            for (int j = 0; j < 16; j++) {
                sum += arr[i][j];
            }
            System.out.println("第" + (i+1) + "行所有元素的累加和是:" + sum);
        }

        System.out.println("---------------------------------------");

        sum = 0;
        for (int i = 0; i < 16; i++){
            for (int j = 0; j < 16; j++) {
                sum += arr[j][i];
            }
            System.out.println("第" + (i+1) + "列所有元素的累加和是:" + sum);
        }

        System.out.println("---------------------------------------");
        sum = 0;
        for (int i = 0; i < 16; i++){
            sum += arr[i][i];
        }
        System.out.println("左上角到右下角的所有元素累加和是:" + sum);

        System.out.println("---------------------------------------");
        sum = 0;
        for (int i = 0; i < 16; i++){
            sum += arr[15-i][i];
        }
        System.out.println("左下角到右上角的所有元素累加和是:" + sum);
    }
}
